home *** CD-ROM | disk | FTP | other *** search
- (****************************************************************************
- *****************************************************************************
- * *
- * SsaveDem.pas: Demo for the Borland Pascal Screen Saver units. *
- * *
- *****************************************************************************
- * *
- * Compiler: BP 7.0 *
- * *
- * The resulting .EXE file must be renamed to .SCR and copied to the *
- * windows directory for Control Panel to find it. Be sure not to *
- * forget the line {$D SCRNSAVE <name>} to give the saver a name. *
- * *
- *****************************************************************************
- * *
- * Copyright ⌐ 1993 Manfred Keul [100031,12]. *
- * *
- * Rev. 0.1 19.4.93 MK IR *
- * *
- ****************************************************************************)
-
- uses OWindows, ODialogs, Wintypes, Winprocs, SSaveWin, SSavePwd, Traps;
-
- {$I savedrc.inc contains rc constants }
- {$R ssavedem.res contains configuration dialog layout }
-
- { $define Lazy } { Define one of these constants...}
- { $define Text }
- { $define Ellipses }
- { $define Spotlight}
- {$define Tubes } {.. to select an animation module }
-
- {****************************************************************************
- * *
- * T M y S a v e r W i n *
- * *
- * Sample screen saver window, descendant of TScSaverWin (unit SSaveWin). *
- * *
- ****************************************************************************}
-
- { Plug in one of the sample savers by $DEFINing one of the above constants.
- Most of the samples do nothing more than to override the DoTheShow method
- of TScSaverWin with their own animation. }
-
- {$ifdef Lazy } {$I LazySavr.pas just blank } {$endif }
- {$ifdef Text } {$I TextSavr.pas some text } {$endif }
- {$ifdef Ellipses } {$I EllpSavr.pas ellipses } {$endif }
- {$ifdef Spotlight} {$I SpotSavr.pas spotlight } {$endif }
- {$ifdef Tubes } {$I TubeSavr.pas tubes } {$endif }
-
- {****************************************************************************
- * *
- * T S c r S a v A p p *
- * *
- * Application object. Generates a window of type TMySaverWin (descendant *
- * of TScSaverWin, unit SSaveWin). Must call the DoTheShow method of this *
- * window within its IdleAction method. *
- * *
- ****************************************************************************}
-
- type
- TScrSavApp = object (TApplication)
- procedure InitMainWindow; virtual;
- function IdleAction: boolean; virtual;
- end;
-
- procedure TScrSavApp.InitMainWindow;
- begin
- MainWindow := New (PMySaverWin, Init (nil, AppName))
- end;
-
- function TScrSavApp.IdleAction: boolean;
- begin
- PMySaverWin (MainWindow)^.DoTheShow; { call animation routine }
- IdleAction := true; { call it again and again and again..}
- end;
-
- {****************************************************************************
- * *
- * T S c r C n f D l g *
- * *
- * Dialog window for screen saver configuration, here: only password. *
- * Descendant objects can contain controls for their individual setup. *
- * *
- ****************************************************************************}
-
- const ConfigClass = 'ScrSavCnfDialog'; { Class name }
-
- type
- PScrCnfDlg = ^TScrCnfDlg;
- TScrCnfDlg = object(TDlgWindow)
- DesktopApplet: HWnd;
- constructor Init (aParent:PWindowsObject; aTitle:PChar);
- destructor Done; virtual;
- function GetClassName: PChar; virtual;
- procedure PWBut (var Msg: TMessage); virtual id_First + IDC_PWBut;
- end;
-
- {****************************************************************************
- * *
- * T S c r C n f D l g . I n i t *
- * - . D o n e *
- * - . G e t C l a s s N a m e *
- * *
- * NOTE: The Configuration Dialog should be modal. Because there is no easy *
- * way to run an OWL TDialog via the DialogBox function, we must *
- * disable/enable the Desktop applet by hand in our Init/Done methods.*
- * *
- ****************************************************************************}
-
- constructor TScrCnfDlg.Init (aParent: PWindowsObject; aTitle: PChar);
- begin
- inherited Init (aParent, aTitle);
- DesktopApplet := GetActiveWindow;
- EnableWindow (DesktopApplet, false);
- end;
-
- destructor TScrCnfDlg.Done;
- begin
- EnableWindow (DesktopApplet, true);
- BringWindowToTop (DesktopApplet);
- inherited Done;
- end;
-
- function TScrCnfDlg.GetClassName: PChar;
- begin
- GetClassName := ConfigClass;
- end;
-
- {****************************************************************************
- * *
- * T S c r C n f D l g . P W B u t *
- * *
- * Responds to the Password button by invoking the password dialog *
- * (imported from unit SSavePwd.) *
- * *
- ****************************************************************************}
-
- procedure TScrCnfDlg.PWBut (var Msg: TMessage);
- begin
- Application^.ExecDialog (New (PPassWordDialog, Init(@Self, 'NewPWDlg')));
- end;
-
-
- {****************************************************************************
- * *
- * T S c r C n f A p p *
- * *
- * Application object for screen saver configuration. Generates a window of *
- * type TScrCnfDlg. *
- * *
- ****************************************************************************}
-
- type
- TScrCnfApp = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- procedure TScrCnfApp.InitMainWindow;
- begin
- MainWindow := New (PScrCnfDlg, Init (nil,'ConfigDlg'));
- end;
-
- {****************************************************************************
- *****************************************************************************
- * *
- * M a i n P r o g r a m *
- * *
- *****************************************************************************
- ****************************************************************************}
-
- {****************************************************************************
- * *
- * A screen saver really is "two programs in one". If started with a "/s" *
- * or "-s" command line parameter, the saver itself should start (in this *
- * implementation: type TScrSavApp). A "/c" or "-c" invokes the configura- *
- * tion (TScrCnfApp). *
- * *
- ****************************************************************************}
-
- var ScrSavApp: TScrSavApp;
- ScrCnfApp: TScrCnfApp;
-
- begin
- if (hPrevInst <> 0) then halt; { don't start twice }
-
- SaverName := AppName; { override default CONTROL.INI heading in unit SSavePwd }
-
- if (Pos ('s', ParamStr(1)) <> 0) or (Pos ('S', ParamStr(1)) <> 0) then
- begin { "s" in command line: run saver }
- ScrSavApp.Init (AppName);
- ScrSavApp.Run;
- ScrSavApp.Done;
- end
- else
- begin { no "s": must be "c"onfiguration }
- { In fact, we don't need an application object here, because all we want
- to do is to run a dialog box: Windows' DialogBox function would be a
- much cheaper solution. OK, we're in OWL here. And since TDialog needs
- an Application, let's give it one: }
- ScrCnfApp.Init (AppName);
- ScrCnfApp.Run;
- ScrCnfApp.Done;
- end;
- end.
-
-